package control
{
	import flash.events.Event;
	import flash.net.URLVariables;
	
	import model.ModelLocator;
	
	import mx.rpc.events.ResultEvent;
	import mx.rpc.http.HTTPService;
	import mx.controls.Alert;
	
	import vo.MyMarker;
	
	public class EditMarker
	{
		 internal var theModel:ModelLocator = ModelLocator.getInstance();
		 private var EditMarkerHttp:HTTPService;
		public function EditMarker()
		{
			EditMarkerHttp = new HTTPService();
			EditMarkerHttp.url = "http://localhost:8080/" + ModelLocator.WEB + "/servlet/EditMarker";
			EditMarkerHttp.addEventListener(ResultEvent.RESULT,EditMarkerResultHandler);
		}
		public function doEditMarker(marker:MyMarker):void{
			var params:URLVariables = new URLVariables();
			params.markername = marker.markername;
			params.creator = marker.creater;
			params.type = marker.type;
			params.latitude = marker.latitude;
			params.longitude = marker.longitude;
			params.description = marker.description;
			params.id = marker.id;
	//		Alert.show("send parems");
			EditMarkerHttp.send(params);
		}
		public function EditMarkerResultHandler(event:ResultEvent):void{
			if(event.result.Result.STATUS == "Successful"){
				theModel.dispatchEvent(new Event(ModelLocator.EDITMARKER_OK));
			}else{
				theModel.dispatchEvent(new Event(ModelLocator.EDITMARKER_FAILED));
			}
		}

	}
}